package net.thermetics.fx.services.impl;

import java.util.List;

import javax.jdo.annotations.PersistenceAware;

import net.thermetics.fx.auth.GaeUser;
import net.thermetics.fx.auth.UserRegistry;
import net.thermetics.fx.services.UserService;

import org.springframework.beans.factory.annotation.Autowired;

import com.google.appengine.api.datastore.Key;

@PersistenceAware
public class UserServiceImpl implements UserService {
	@Autowired
	private UserRegistry userRegistry;
	
	@Override
	public boolean deleteUser(String username) {
		return false;
	}

	@Override
	public List<GaeUser> getAllUsers() {
		throw new UnsupportedOperationException("Not yet implemented");
	}

	@Override
	public GaeUser getUser(String username) {
		return userRegistry.findUser(username);
	}
	
	@Override
	public GaeUser getUser(Key key) {
		return userRegistry.findUser(key.getName());
	}

	@Override
	public boolean updateUser(GaeUser user) {
		userRegistry.persistUser(user);
		return true;
	}

}
